#include <algorithm>
#include <iostream>

using namespace std;

const int MAXN = 1e3 + 10;
const int MAXV = 2e4 + 10;
const int bias = 2 * MAXV;
const int MOD = 998244353;
int n, ans = 0;
int a[MAXN];
int f[MAXN][2 * MAXV];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
        ans++;
        for (int j = i - 1; j >= 0; j--) {
            f[i][a[i] - a[j] + bias] += f[j][a[i] - a[j] + bias] + 1;
            f[i][a[i] - a[j] + bias] %= MOD;
            ans += f[j][a[i] - a[j] + bias] + 1;
            ans %= MOD;
        }
    }
    cout << ans;
}